import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:life_service/model/bank.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

class MineEvaluateController extends GetxController {}

class MineCouponsController extends GetxController {}

class MineUsedInfoController extends GetxController {}

class MineUsedAddController extends GetxController {
  final List<String> types = ['身份证', '护照', '军官证'];

  RxInt gender = RxInt(2);
}

class MineWalletBillController extends GetxController {}

class MineWalletRechargeController extends GetxController {
  List<Rx<BankModel>> banks = [
    Rx(BankModel(name: '农业银行', icon: 'abc.png')),
    Rx(BankModel(name: '中国银行', icon: 'boc.png')),
    Rx(BankModel(name: '建设银行', icon: 'ccb.png')),
    Rx(BankModel(name: '招商银行', icon: 'cmb.png')),
    Rx(BankModel(name: '工商银行', icon: 'icbc.png')),
    Rx(BankModel(name: '邮政银行', icon: 'psbc.png')),
  ];
}

class MineWalletCompleteController extends GetxController {}

class MineMemberCenterController extends GetxController {
  RxInt memberIndex = RxInt(0);

  List<String> memberLevel = ['普通会员', '白银会员', '黄金会员', '白金会员'];
}

class MineOrderListController extends GetxController
    with GetTickerProviderStateMixin {
  late TabController controller;
  List<String> tabs = ['全部订单', '待付款', '待入住', '已消费'];

  @override
  void onInit() {
    controller = TabController(length: tabs.length, vsync: this);
    super.onInit();
  }

  @override
  void onClose() {
    controller.dispose();
    super.onClose();
  }
}

class MineWalletCardController extends GetxController {
  RxList<BankModel> pageList = [
    BankModel(name: '农业银行', icon: 'abc.png'),
    BankModel(name: '中国银行', icon: 'boc.png'),
    BankModel(name: '建设银行', icon: 'ccb.png'),
    BankModel(name: '招商银行', icon: 'cmb.png'),
    BankModel(name: '工商银行', icon: 'icbc.png'),
    BankModel(name: '邮政银行', icon: 'psbc.png'),
  ].obs;

  final RefreshController refreshController = RefreshController();

  @override
  void onClose() {
    super.onClose();
    refreshController.dispose();
  }

  Future<void> onRefresh() async {
    /// 发起请求
    await Future.delayed(const Duration(milliseconds: 2000));
    refreshController.refreshCompleted(resetFooterState: true);
  }

  Future<void> onLoading() async {
    /// 发起请求
    await Future.delayed(const Duration(milliseconds: 2000));

    /// if failed, use loadFailed(), if no data return, use LoadNodata()
    if (pageList.length > 12) {
      return refreshController.loadNoData();
    }
    pageList.add(BankModel(name: '工商银行', icon: 'icbc.png'));
    pageList.add(BankModel(name: '工商银行', icon: 'icbc.png'));
    pageList.add(BankModel(name: '工商银行', icon: 'icbc.png'));
    pageList.add(BankModel(name: '招商银行', icon: 'cmb.png'));

    /// 添加
    refreshController.loadComplete();
  }
}
